<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // new Promise((resolve, reject) => {
    //   resolve()
    // }).then(
    //   value => {
    //     return new Promise((resolve, reject) => {
    //       setTimeout(() => {
    //         reject("处理失败")
    //       }, 2000)
    //     })
    //   },
    //   reason => console.log('error:' + reason)
    // ).then(value => {
    //   console.log(value)
    // }, reason => console.log(reason))

    // 只要你返回，**后面的then就是前面返回的promise的处理**
    new Promise((resolve, reject) => {
      resolve()
    }).then(
      value => {
        return new Promise((resolve, reject) => {
          setTimeout(() => {
            reject("处理失败")
          }, 2000)
        })
        .then(null, r => {
          return 'abc'
        })
      },
      reason => console.log('error:' + reason)
    ).then(value => {
      console.log('成功' + value)
    }, reason => console.log('失败' + reason))
  </script>
</body>
</html>